/**
 *@description:TODO
 * @author: cai
 *@time:2017年7月3日下午4:24:39
 */
package com.pos.modules.inquery.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.pos.R;
import com.pos.modules.inquery.bean.BillBean;
import com.pos.toolbox.FinancialUtils;

import java.util.List;

/**
 * @description:订单list adapter
 * @author cai
 * @time:2017年7月3日下午4:24:39
 */
public class BillListAdapter extends ArrayAdapter<BillBean> {

	public BillListAdapter(Context context, List<BillBean> billList) {
		super(context, 0, billList);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(R.layout.bill_list_item_layout, null);
			holder = new ViewHolder();
			holder.text_code = (TextView) convertView.findViewById(R.id.text_code);
			holder.text_time = (TextView) convertView.findViewById(R.id.text_time);
			holder.text_amount = (TextView) convertView.findViewById(R.id.text_amount);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		final BillBean item = getItem(position);
		holder.text_code.setText(item.getOrderCode());
		holder.text_time.setText(item.getOrderDatetime());
		holder.text_amount.setText(FinancialUtils.fen2yuan(item.getTotalAmount()));

		return convertView;
	}

	static class ViewHolder {
		public TextView text_code, text_time, text_amount;
	}

}
